package com.gsit.omega.ea.domain;

import com.gsit.omega.ea.utils.TaskStatus;
import java.util.Calendar;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Enumerated;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.roo.addon.entity.RooEntity;
import org.springframework.roo.addon.javabean.RooJavaBean;
import org.springframework.roo.addon.tostring.RooToString;

@RooJavaBean
@RooToString
@RooEntity(finders = { "findTasksByStatus" })
public class Task {

    @NotNull
    private String code;

    @NotNull
    private String name;

    private String description;

    @NotNull
    @Temporal(TemporalType.TIMESTAMP)
    @DateTimeFormat(style = "M-")
    private Calendar startDate;

    @Temporal(TemporalType.TIMESTAMP)
    @DateTimeFormat(style = "M-")
    private Calendar endDate;

    @ManyToOne
    private User assignTo;

    @ManyToMany(cascade = CascadeType.ALL)
    private Set<Activity> activities = new HashSet<Activity>();

    @Enumerated
    private TaskStatus status;
}
